package com.ybear.ybnetworkutil.http;

import java.util.Date;

import okhttp3.Headers;

/**
 * 请求头
 */
public class Header {
    private Headers.Builder mBuilder;
    private Header() { mBuilder = new Headers.Builder(); }
    public static Header create() { return HANDLER.I; }
    private static final class HANDLER { private static final Header I = new Header(); }

    Headers callHeader() { return mBuilder.build(); }

    public void add(String name, String value) { mBuilder.add(name, value); }

    public void add(String name, Date value) { mBuilder.add(name, value); }

    public void add(String line) { mBuilder.add(line); }

    public void addUnsafeNonAscii(String name, String value) {
        mBuilder.addUnsafeNonAscii(name, value);
    }

    public void addAll(Header header) { mBuilder.addAll( header.callHeader() ); }

    public String get(String name) { return mBuilder.get(name); }

    public void set(String name, String value) { mBuilder.set(name, value); }

    public void set(String name, Date value) { mBuilder.set(name, value); }

    public void removeAll(String name) { mBuilder.removeAll(name); }

    public void clear() { mBuilder = new Headers.Builder(); }
}
